package controls.challengeHistory {
	
	import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
	
	
	/**
	 * A utility class containing all of the label functions for the challenge history datagrid.
	 * Label functions are necessary if, in the xml, the label you are looking for is not an attribute of the parent element.
	 * In this case, the solution node is a child of the challenge node, so the label must be derived with a label function.
	 * @author Brent Kersanske
	 */ 
	public class ChallengeHistoryLabelFunctions	{
		
		private static var NOT_APPLICABLE:String = "N/A";

		/**
		 * Label function for the solver column of the datagrid.
		 */ 
      	public static function labelSolverColumn(item:Object, column:AdvancedDataGridColumn):String {
        	var node:XML = XML(item);
        	if(node.solution!= null) {
        		return node.solution.@solver;
        	} else {
        		return NOT_APPLICABLE;
        	}
        }
        
       /**
        * Label function for the account change column of the datagrid. 
        */ 
        public static function labelAccountChangeColumn(item:Object, column:AdvancedDataGridColumn):String {
			var node:XML = XML(item);
        	if(node.solution != null) {
        		return node.solution.@accountChange;
        	}  else {
        		return NOT_APPLICABLE;
        	}		
		}

		/**
		 * Label the FSAT column of the datagrid.
		 */ 
		public static function labelFSatColumn(item:Object, column:AdvancedDataGridColumn):String {
			var node:XML = XML(item);
        	if(node.solution != null) {
        		return node.solution.@fsat;
        	}  else {
        		return NOT_APPLICABLE;
        	}	
		}
        
       /**
        * Label the solve accept difference column.
        */ 
        public static function labelSolveAcceptDiffColumn(item:Object, column:AdvancedDataGridColumn):String {
        	var node:XML = XML(item);
        	if(node.solution != null) {
        		return node.solution.@diffFromAccept;
        	}  else {
        		return NOT_APPLICABLE;
        	}
        }
	}
}